<template>
  <div id="myBar4" :style="{ width: '460px', height: '285px' }"></div>
</template>

<script>
export default {
  name: "pie1",
  props: {
    bar4data1: {
      type: Array,
      default: function () {
        return [];
      },
    },
    bar4data2: {
      type: Array,
      default: function () {
        return [];
      },
    },
    bar4data3: {
      type: Array,
      default: function () {
        return [];
      },
    },
    bar4data4: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  data() {
    return {};
  },
  watch: {
    bar4data1() {
      this.init();
    },
    bar4data2() {
      this.init();
    },
    bar4data3() {
      this.init();
    },
    bar4data4() {
      this.init();
    },
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      let bar4 = this.$echarts.init(document.getElementById("myBar4"));
      bar4.setOption({
        title: {
        //   text: "关键技术数量",
        //   y: "center",
        },
        legend: {
          data: ['低风险', '中风险', '高风险']
        },
        tooltip: {},
        xAxis: [
          { type: "category", 
          data: this.bar4data1 }
        ],
        yAxis: {
          name: "关\n键\n技\n术\n数\n量",
          nameLocation: "left",
          nameTextStyle: {
            color: "#fff",
            fontSize: 14,
            // padding: [0, 40, -100, 0],
          },
        },
        // Declare several bar series, each will be mapped
        // to a column of dataset.source by default.
        series: [
          {
            name: '低风险',
            type: "bar",
            barWidth: "10%",
            data: this.bar4data2,
            itemStyle: {
              normal: {
                color: '#3168c3',
                barBorderRadius: [20, 20, 20, 20],
              },
            },
          },
          {
            name: '中风险',
            type: "bar",
            barWidth: "10%",
            data: this.bar4data3,
            itemStyle: {
              normal: {
                color: '#4fade0',
                barBorderRadius: [20, 20, 20, 20],
              },
            },
          },
          {
            name: '高风险',
            type: "bar",
            barWidth: "10%",
            data: this.bar4data4,
            itemStyle: {
              normal: {
                color: '#9ad4e0',
                barBorderRadius: [20, 20, 20, 20],
              },
            },
          },
        ],
      });
    },
  },
};
</script>

<style>
</style>